package com.apexbrain.apexbrainserver.controller;

import com.apexbrain.apexbrainserver.mapper.QuestionMapper;
import com.apexbrain.apexbrainserver.pojo.Question;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * tb_question表的controller
 */
@Controller
@RequestMapping("/question")
public class QuestionController {
    @Autowired
    private QuestionMapper questionMapper;

    /**
     * 根据id获取问题
     * @param question_id http请求所带参数
     * @return 返回问题对象
     */
    @GetMapping("/get_question")
    @ResponseBody
    public Question getQuestionId(@RequestParam int question_id)
    {
        return questionMapper.getQuestion(question_id);
    }
    /**
     * 获取问题数量
     * @return 返回问题的数量
     */
    @GetMapping("/get_question_count")
    @ResponseBody
    public int getQuestionCount()
    {
        return questionMapper.getQuestionCount();
    }

}
